//
//  StatusCellBottomView.swift
//  Swiftsweibo
//
//  Created by 张鹏飞 on 16/1/11.
//  Copyright © 2016年 张鹏飞. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    
    //MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //MARK: - 懒加载控件
    private lazy var retweetedButton: UIButton = UIButton(title: " 转发", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    private lazy var commentButton:UIButton = UIButton(title: " 评论", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    private lazy var likeButton: UIButton = UIButton(title: " 赞", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")

}

//MARK: - 设置界面
extension StatusCellBottomView {

    private func setUpUI() {
    
        //1.背景颜色
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        
        //2.添加控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        //3.自动布局
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.size.equalTo(retweetedButton.snp_size)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(commentButton.snp_top)
            make.bottom.equalTo(commentButton.snp_bottom)
            make.size.equalTo(commentButton.snp_size)
            make.right.equalTo(self.snp_right)
        }
        
        //分隔视图
        let sepV1 = sepView()
        let sepV2 = sepView()
        
        addSubview(sepV1)
        addSubview(sepV2)
        
        let w = 0.5
        let scale = 0.4
        
        sepV1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
        sepV2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
    }
    
    //MARK: - 创建分隔视图
    private func sepView() -> (UIView) {
    
        let v = UIView()
        
        v.backgroundColor = UIColor.darkGrayColor()
        
        return v
    }
}
